import '../bar/bar_entity.dart';

/// 柱状图绘制方向
enum HorizontalBarGravity {
  /// 从网格顶部往下绘制
  top,

  /// 从网格中间向两边绘制
  center,

  /// 从网格底部网上绘制
  bottom
}

/// 柱状图分组数据
class HorizontalBarGroupEntity {
  const HorizontalBarGroupEntity(
      {required this.values,
      this.barOffset = 2,
      this.gravity = HorizontalBarGravity.center});

  final List<BarEntity> values;

  /// 柱状图之间的间距
  final double barOffset;
  final HorizontalBarGravity gravity;
}

/// 柱状图数据
class HorizontalBarData {
  HorizontalBarData(
      {List<BarEntity>? values,
      HorizontalBarGravity gravity = HorizontalBarGravity.center})
      : this.group(
          groups: values
              ?.map((e) =>
                  HorizontalBarGroupEntity(values: [e], gravity: gravity))
              .toList(),
        );

  /// y轴每个网格柱形图有多个
  const HorizontalBarData.group({this.groups});

  /// 柱形分组数据
  final List<HorizontalBarGroupEntity>? groups;
}
